package com.su.lesson04;

import javax.swing.*;
import java.awt.*;

public class JFframeDemo02 {
    public static void main(String[] args) {
        new MyJframe().init();
    }
}
class MyJframe extends JFrame {
    public void init() {
        this.setBounds(100, 100, 450, 300);
        JLabel label = new JLabel("欢迎来到我的世界！");
        this.add(label);
        //让文本标签居中
        label.setHorizontalAlignment(SwingConstants.CENTER);
        this.setVisible(true);
        //获得一个容器
        Container container = this.getContentPane();
        container.setBackground(Color.yellow);

        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
